# -*- coding: utf-8 -*-
from src.game.entity.bullet import EntityBullet
from src.game.entity.rocket import EntityRocket
import pygame

class Shoot:

    def handle(self, client):
        entity = EntityBullet()
        x, y = client.world.player.getViewingVector()
        entity.x = client.world.player.x + x
        entity.y = client.world.player.y + y
        mx, my = pygame.mouse.get_pos()
        mx = mx / 64. + client.window.viewport.x
        my = my / 64. + client.window.viewport.y
        entity.setTarget(mx, my)
        client.world.spawnEntity(entity)
        
    def handleUp(self, client):
        pass

class ShootRocket:

    def handle(self, client):
        entity = EntityRocket()
        x, y = client.world.player.getViewingVector()
        entity.x = client.world.player.x + x
        entity.y = client.world.player.y + y
        mx, my = pygame.mouse.get_pos()
        mx = mx / 64. + client.window.viewport.x
        my = my / 64. + client.window.viewport.y
        entity.setTarget(mx, my)
        client.world.spawnEntity(entity)
        
    def handleUp(self, client):
        pass